package com.sinog.front.controller.biz;

import com.sinog.core.domain.JieKouLog;
import com.sinog.core.model.UserDTO;
import com.sinog.core.utilbean.Constants;
import com.sinog.core.utilbean.ReturnCode;
import com.sinog.front.feign.biz.SeeJiekouLogService;
import com.sinog.front.service.user.UserFacade;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
import java.util.Map;

/**
 * @author ypc
 * @desc 司法部管理员-系统管理-接口对接日志
 * @date 2022/10/19
 */
@RestController
public class SeeJiekouLogController {

    @Autowired
    private SeeJiekouLogService seeJiekouLogService;
    @Autowired
    private UserFacade userFacade;

    /**
     * 司法部管理员-系统管理-接口对接日志-得到所有省份
     * @return List<Map<String, String>>
     */
    @RequestMapping("/azbj/seelog/getprovince")
    public List<Map<String, String>> getAllProvince() {
        List<Map<String, String>> province = seeJiekouLogService.getAllProvince();
        return province;
    }

    /**
     * 查询所有省份的接口对接日志信息
     * @param params 前端框架的参数
     * @return String
     */
    @RequestMapping("/azbj/seelog/getAllLog")
    public String selectAllLog(@RequestParam Map<String, Object> params) {
        UserDTO userDTO = userFacade.getAuthentication();
        if (Constants.RoleId.ROLE_ID_AB.equals(userDTO.getRoleid())) {
            return seeJiekouLogService.selectAllLog(params);
        }
        return ReturnCode.NO_PERMISSION.message();
    }

    /**
     * 根据id查询所有省份的接口对接日志信息
     * @param id
     * @return JieKouLog 实体类
     */
    @RequestMapping("/azbj/seelog/getCodeById")
    public JieKouLog selectCodeById(@RequestParam String id) {
        return seeJiekouLogService.selectCodeById(id);
    }
}